<template>
  <div class="app-container">
    <!-- 查询和其他操作 -->
    <div class="filter-container">
      <el-input v-model="listQuery.title" clearable class="filter-item" style="width: 200px;" :placeholder="$t('openapi.list.searchPlaceholder')" />
      <el-button class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter">{{ $t('openapi.list.search') }}</el-button>
    </div>

    <!-- 查询结果 -->
    <el-table
      v-loading="listLoading"
      :data="list"
      size="small"
      :element-loading-text="$t('openapi.list.searching')"
      border
      fit
      highlight-current-row
    >

      <el-table-column align="center" label="API ID" width="80" prop="id" />

      <el-table-column align="center" :label="$t('openapi.list.title')" min-width="100" prop="title" />

      <el-table-column align="center" :label="$t('openapi.list.idTag')" min-width="100" prop="idTag" />

      <el-table-column align="center" :label="$t('openapi.list.description')" min-width="150" prop="description" />

      <el-table-column align="center" :label="$t('openapi.list.gmtCreate')" prop="gmtCreate">
        <template slot-scope="scope">{{ scope.row.gmtCreate | formatTime }}</template>
      </el-table-column>

      <el-table-column align="center" :label="$t('openapi.list.operation')" width="250" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button type="primary" size="mini" @click="showApiInfo(scope.row)">{{ $t('openapi.list.apiDetail') }}</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="listQuery.page"
      :limit.sync="listQuery.limit"
      @pagination="getList"
    />

    <el-tooltip placement="top" :content="$t('openapi.list.toTop')">
      <back-to-top :visibility-height="100" />
    </el-tooltip>

  </div>
</template>

<script>
import BackToTop from '@/components/BackToTop'
import Pagination from '@/components/Pagination'

export default {
  name: 'OpenApiList',
  components: { BackToTop, Pagination },
  data() {
    return {
      listQuery: {
        page: 1,
        limit: 20,
        title: ''
      },
      total: 2,
      listLoading: false,
      list: [
        {
          id: 1,
          productId: 2,
          title: '系统时间',
          idTag: 'system.currentTimeMillis',
          description: '获取当前系统时间戳或文本时间',
          gmtCreate: 1591598917738
        },
        {
          id: 2,
          productId: 2,
          title: '城市温度',
          idTag: 'realtime.getCityTemperature',
          description: '传入cityCode，获取当前城市温度',
          gmtCreate: 1591598917738
        }
      ]
    }
  },
  methods: {
    // 查询
    getList() {

    },
    handleFilter() {
      this.listQuery.page = 1
      this.getList()
    },
    showApiInfo() {

    }
  }
}
</script>
